package entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="T_RETAIL_ORDER")
public class RetailOrder implements Serializable{

	private static final long serialVersionUID = 1L;
	private int retailOrderId;
	private String retailOrderNumber;
	private String paymentMethod;
	private Customer customer;
	private Status status;
	private BigDecimal netValue;
	private BigDecimal vat;
	private BigDecimal grossValue;
	private Set<RetailOrderDetails> orderDetails = new HashSet<>();
	private Set<Invoice> invoices = new HashSet<>();
	
	public RetailOrder(){
	}
	
	public RetailOrder(String retailOrderNumber, String paymentMethod, Status status, BigDecimal netValue,
			BigDecimal vat, BigDecimal grossValue){
		this.retailOrderNumber = retailOrderNumber;
		this.paymentMethod = paymentMethod;
		this.status = status;
		this.netValue = netValue;
		this.vat = vat;
		this.grossValue = grossValue;
	}
	
	public RetailOrder(String retailOrderNumber, String paymentMethod, Status status, Customer customer,
			BigDecimal netValue, BigDecimal vat, BigDecimal grossValue){
		this.retailOrderNumber = retailOrderNumber;
		this.paymentMethod = paymentMethod;
		this.status = status;
		this.customer = customer;
		this.netValue = netValue;
		this.vat = vat;
		this.grossValue = grossValue;
	}
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name="DETAIL_ORDER_ID",unique = true, nullable = false)
	public int getRetailOrderId() {
		return retailOrderId;
	}

	public void setRetailOrderId(int retailOrderId) {
		this.retailOrderId = retailOrderId;
	}

	@Column(name="DETAIL_ORDER_NUMBER", nullable=false)
	public String getRetailOrderNumber() {
		return retailOrderNumber;
	}

	public void setRetailOrderNumber(String retailOrderNumber) {
		this.retailOrderNumber = retailOrderNumber;
	}

	@Column(name="PAYMENT_METHOD", nullable=false)
	public String getPaymentMethod() {
		return paymentMethod;
	}

	public void setPaymentMethod(String paymentMethod) {
		this.paymentMethod = paymentMethod;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "RETAIL_ORDER_CUSTOMER_ID", nullable = false)
	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "RETAIL_ORDER_STATUS_ID", nullable = false)
	public Status getStatus() {
		return status;
	}

	public void setStatus(Status status) {
		this.status = status;
	}

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "retailOrder", cascade = CascadeType.ALL)
	public Set<RetailOrderDetails> getOrderDetails() {
		return orderDetails;
	}

	public void setOrderDetails(Set<RetailOrderDetails> orderDetails) {
		this.orderDetails = orderDetails;
	}

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "retailOrder", cascade = CascadeType.ALL)
	public Set<Invoice> getInvoices() {
		return invoices;
	}

	public void setInvoices(Set<Invoice> invoices) {
		this.invoices = invoices;
	}

	@Column(name="NET_VALUE", nullable=false)
	public BigDecimal getNetValue() {
		return netValue;
	}

	public void setNetValue(BigDecimal netValue) {
		this.netValue = netValue;
	}

	@Column(name="VAT", nullable=false)
	public BigDecimal getVat() {
		return vat;
	}

	public void setVat(BigDecimal vat) {
		this.vat = vat;
	}

	@Column(name="GROSS_VALUE", nullable=false)
	public BigDecimal getGrossValue() {
		return grossValue;
	}

	public void setGrossValue(BigDecimal grossValue) {
		this.grossValue = grossValue;
	}
	
	
	
}
